<template>
  <Layout :info="userInfo" @logout="logout" :infos="infos" logo="培训管理中心">
    <router-view></router-view>
  </Layout>
</template>

<script>
import Layout from '@/view/layout/main'
import login from '@/view/layout/login'
export default {
  components: {
    Layout,
    login
  },
  data () {
    return {
      userInfo: { name: 'admin' },
      infos: [
        {
          name: 'admin',
          label: '管理员登录',
          icon: 'ios-people'
        },
        {
          name: 'member',
          label: '会员管理',
          icon: 'md-cloudy'
        },
        {
          name: 'company',
          label: '公司管理',
          icon: 'md-cloudy'
        },
        {
          name: 'course',
          label: '培训课程管理',
          icon: 'md-cloudy'
        },
        // {
        //   name: 'coursechildren',
        //   label: '培训子课程管理',
        //   icon: 'md-cloudy'
        // },
        {
          name: 'exam',
          label: '答题模块',
          icon: 'md-cloudy'
        },
        {
          name: 'statistics',
          label: '培训统计',
          icon: 'md-cloudy'
        }
      ]
    }
  },
  created () {
    let userInfo = sessionStorage.getItem('userInfo')
    console.log('userInfo: ', userInfo)
    if (!userInfo) {
      this.$router.push('/login')
    } else {
      this.userInfo = JSON.parse(userInfo)
    }
  },
  methods: {
    logout (v) {
      this.userInfo = null
      sessionStorage.removeItem('userInfo')
      this.$router.push('/login')
    }
  }
}
</script>
